
import beans.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 启动类 通过ApplicationContext来获取bean
 */

public class App {
    public static void main(String[] args) {
        //1.得到spring的上下文对象
        ApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
        //2.获取指定的Bean对象
        User user = (User) context.getBean("user");
//        3.使用bean
        user.sayHi("xue");

    }
}
